<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>通知模板管理列表</title>
    <s:head/>
</head>
<script type="text/javascript">

    var msgTemplateState = $.mrdForm.ajaxdp("dropdown-useState");

    $(function () {

        $("#mrdForm").mrdForm({
            title: "查询列表",
            columns: [{
                name: "process.processName",
                label: "业务流程名称"
            }],
            buttons: {
                'custom': [
                    {id: "addMsgSetting", value: "添加通知模板", click: add},
                    {id: "editMsgSetting", value: "编辑通知模板", click: edit}
                ]
            },
            grid: {
                id: "columnGrid",
                url: "msgTemplate-listMsgTemplate?sysMsgTemplate.process.bizType=" + $("#bizType").val(),
                colNames: ["id", "流程名称", "通知模板内容", "通知模板状态", "通知模板备注"],
                colModel: [{
                    name: 'id',
                    index: 'id',
                    hidden: true,
                    align: 'center'
                }, {
                    name: 'process.processName',
                    index: 'processName',
                    label: '流程名称',
                    align: 'center'
                }, {
                    name: 'content',
                    index: 'content',
                    label: '模板内容',
                    align: 'center'
                }, {
                    name: 'useState',
                    index: 'useState',
                    label: '状态',
                    align: 'center',
                    dropdown: msgTemplateState
                }, {
                    name: 'note',
                    index: 'note',
                    label: '备注',
                    align: 'center'
                }],
                title: "通知管理列表",
                jsonReader: {
                    //从哪个json对象中取值
                    root: "sysMsgTemplates",
                    id: "id"
                },
                onSelectRow: function (processId) {
                },
                ondblClickRow: function (id) {
                    location.href = ".../base/msgTemplate-manage?sysMsgTemplate.id=" + id + "&sysMsgTemplate.process.bizType=" + $("#bizType").val();
                }
            }
        });
        $("#mrdForm").mrdForm("resize");
    });

    function add() {
        location.href = ".../base/msgTemplate-manage?sysMsgTemplate.process.bizType=" + $("#bizType").val();
    }

    function edit() {
        var selected_rowid = $("#columnGrid").jqGrid("getGridParam", "selrow");
        if (!selected_rowid || selected_rowid == "" || selected_rowid == null) {
            alert("请选择需要编辑的通知模板");
            return;
        }
        var rowData = $("#columnGrid").getRowData(selected_rowid);
        location.href = "msgTemplate-manage?sysMsgTemplate.id=" + rowData.id + "&sysMsgTemplate.process.bizType=" + $("#bizType").val();
    }

</script>
<body>
<input type="hidden" id="bizType" value="${sysMsgTemplate.process.bizType}"/>
<div id="mrdForm"></div>
</body>
</html>
